﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;

/// <summary>
/// Summary description for AccountDAO
/// </summary>
public class UserDAO:DBConnect
{
    string SQL_GET_USER = "select * from members";
	public UserDAO()
	{		
	}
    public bool Login(string user, string pass)
    {
            try{
            SqlCommand cmd = new SqlCommand(SQL_GET_USER, conn);
            if (ConnectDB())
            {

                SqlDataReader rd = cmd.ExecuteReader();
                while (rd.Read())
                {
                    User us = new User();

                    us.Member_login = rd.GetString(0);
                    us.Member_password = rd.GetString(1);
                    if (user.Equals(us.Member_login) && pass.Equals(us.Member_password))
                    {
                        Disconnect();
                        return true;
                    }
                }
                Disconnect();
            }
                 
            }catch(SqlException e)
            {
                Disconnect();
                return false;
            }
        
      
        return false;
    }
}